package yl.hs.bmipfull.controllers.dataCockpit;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.dataCockpit.ISaleCockpitService;
import yl.hs.bmipfull.service.vehiclemanage.ITruckInfoService;
import yl.hs.bmipfull.viewmodels.PageQuery;
import yl.hs.bmipfull.viewmodels.WebResult;

/**
 * @author 谢东
 * @apiNote 数据驾驶舱--销售看板
 * @since 2022/8/30 15:36 创建
 */
@RequestMapping("/api/dataCockpit/saleCockpit")
@Api(value = "数据驾驶舱--销售看板", tags = "数据驾驶舱--销售看板")
@RestController
public class SaleCockpitController extends ControllerBase {


    @Autowired
    ISaleCockpitService saleCockpitService;
    @Autowired
    ITruckInfoService service;

    @ApiOperation(value = "CRM基本情况-销售看板基本信息", notes = "CRM基本情况-销售看板基本信息")
    @RequestMapping(value = "saleBasicInfo",method = RequestMethod.GET)
    public WebResult saleBasicInfo(){
        return  success("查询成功",saleCockpitService.saleBasicInfo());
    }


    @ApiOperation(value = "CRM基本情况-销售情况", notes = "CRM基本情况-销售情况")
    @RequestMapping(value = "saleSituation/{timeType}",method = RequestMethod.GET)
    public WebResult saleSituation(@ApiParam(value = "时间类型")@PathVariable int timeType){
        return  success("查询成功",saleCockpitService.saleSituation(timeType));
    }

    @ApiOperation(value = "CRM基本情况-产品销售排行", notes = "CRM基本情况-产品销售排行")
    @RequestMapping(value = "ProductSalesRanking/{timeType}",method = RequestMethod.GET)
    public WebResult ProductSalesRanking(@ApiParam(value = "时间类型")@PathVariable int timeType){
        return  success("查询成功",saleCockpitService.ProductSalesRanking(timeType));
    }

    @ApiOperation(value = "销售经理销量排行",notes = "CRM基本情况")
    @GetMapping("saleOrder/{timeType}")
    public WebResult salerSaleOrder(@ApiParam(value = "时间类型，年：1/月：0")@PathVariable int timeType){
        try{
            return success("ok",saleCockpitService.saleOrder(timeType));
        }
        catch (Exception ee){
            return error(ee);
        }
    }
    @ApiOperation(value = "CRM基本情况-销售重量趋势", notes = "CRM基本情况-销售重量趋势")
    @RequestMapping(value = "saleNetWeightTrendByMonth",method = RequestMethod.GET)
    public WebResult saleNetWeightTrendByMonth(){
        return  success("查询成功",saleCockpitService.saleNetWeightTrendByMonth());
    }

}
